﻿namespace Forms
{
    using Forms.My;
    using Forms.My.Resources;

    using Microsoft.VisualBasic.CompilerServices;

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class frmFA : Form
    {
        [AccessedThroughProperty("butDel")]
        private ToolStripButton _butDel;
        [AccessedThroughProperty("butEdit")]
        private ToolStripButton _butEdit;
        [AccessedThroughProperty("butNew")]
        private ToolStripButton _butNew;
        [AccessedThroughProperty("butOk")]
        private Button _butOk;
        [AccessedThroughProperty("DatenschemaBMW")]
        private DatenschemaBMW _DatenschemaBMW;
        [AccessedThroughProperty("ListBoxFA")]
        private ListBox _ListBoxFA;
        [AccessedThroughProperty("TABFinanzArtenBindingSource")]
        private BindingSource _TABFinanzArtenBindingSource;
        [AccessedThroughProperty("ToolStrip1")]
        private ToolStrip _ToolStrip1;
        private IContainer components;
        public fDetailMode fMode;

        [DebuggerNonUserCode]
        public frmFA()
        {
            base.FormClosed += new FormClosedEventHandler(this.frmFA_FormClosed);
            base.Load += new EventHandler(this.frmFA_Load);
            this.InitializeComponent();
        }

        private void butDel_Click(object sender, EventArgs e)
        {
            if (this.ListBoxFA.SelectedItem != null)
            {
                string[] strArray = this.ListBoxFA.SelectedItem.ToString().Split(new char[] { ',' });
                MyProject.Forms.Main.cs.Table_Finanzierungsarten.Select("FA_ID = " + strArray[2])[0].Delete();
                MyProject.Forms.Main.cs.Table_Finanzierungsarten.AcceptChanges();
                this.UpdateList();
                foreach (DataRow row in MyProject.Forms.Main.cs.Table_Auswertung.Select("FA_ID = " + strArray[2]))
                {
                    row["FA_ID"] = DBNull.Value;
                }
                MyProject.Forms.Main.cs.Table_Auswertung.AcceptChanges();
            }
        }

        private void butEdit_Click(object sender, EventArgs e)
        {
            this.fMode = fDetailMode.fEdit;
            MyProject.Forms.frmFA_Add.ShowDialog();
        }

        private void butNew_Click(object sender, EventArgs e)
        {
            this.fMode = fDetailMode.fNew;
            MyProject.Forms.frmFA_Add.ShowDialog();
        }

        private void butOk_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing && (this.components != null))
                {
                    this.components.Dispose();
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }

        private void frmFA_FormClosed(object sender, FormClosedEventArgs e)
        {
            MyProject.Forms.Main.InitData(Main.TableType.Auswertung, MyProject.Forms.frmAuswertung.cmbFilter.SelectedIndex);
        }

        private void frmFA_Load(object sender, EventArgs e)
        {
            this.UpdateList();
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            this.components = new Container();
            this.butOk = new Button();
            this.ToolStrip1 = new ToolStrip();
            this.butNew = new ToolStripButton();
            this.butEdit = new ToolStripButton();
            this.butDel = new ToolStripButton();
            this.ListBoxFA = new ListBox();
            this.TABFinanzArtenBindingSource = new BindingSource(this.components);
            this.DatenschemaBMW = new DatenschemaBMW();
            this.ToolStrip1.SuspendLayout();
            ((ISupportInitialize) this.TABFinanzArtenBindingSource).BeginInit();
            this.DatenschemaBMW.BeginInit();
            this.SuspendLayout();
            this.butOk.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            Point point = new Point(0xd9, 0x143);
            this.butOk.Location = point;
            this.butOk.Name = "butOk";
            Size size = new Size(0x71, 0x1b);
            this.butOk.Size = size;
            this.butOk.TabIndex = 11;
            this.butOk.Text = "Ok";
            this.butOk.UseVisualStyleBackColor = true;
            this.ToolStrip1.Items.AddRange(new ToolStripItem[] { this.butNew, this.butEdit, this.butDel });
            point = new Point(0, 0);
            this.ToolStrip1.Location = point;
            this.ToolStrip1.Name = "ToolStrip1";
            size = new Size(0x156, 0x19);
            this.ToolStrip1.Size = size;
            this.ToolStrip1.TabIndex = 15;
            this.ToolStrip1.Text = "ToolStripFA";
            this.butNew.Image = Resources.Symbol_New;
            this.butNew.ImageTransparentColor = Color.Magenta;
            this.butNew.Name = "butNew";
            size = new Size(0x31, 0x16);
            this.butNew.Size = size;
            this.butNew.Text = "Neu";
            this.butEdit.Image = Resources.Symbol_Edit;
            this.butEdit.ImageAlign = ContentAlignment.BottomCenter;
            this.butEdit.ImageTransparentColor = Color.Magenta;
            this.butEdit.Name = "butEdit";
            size = new Size(0x53, 0x16);
            this.butEdit.Size = size;
            this.butEdit.Text = "Bearbeiten";
            this.butDel.Image = Resources.Symbol_Delete;
            this.butDel.ImageAlign = ContentAlignment.BottomCenter;
            this.butDel.ImageTransparentColor = Color.Magenta;
            this.butDel.Name = "butDel";
            size = new Size(0x4e, 0x16);
            this.butDel.Size = size;
            this.butDel.Text = "Entfernen";
            this.ListBoxFA.DrawMode = DrawMode.OwnerDrawFixed;
            this.ListBoxFA.FormattingEnabled = true;
            point = new Point(0, 0x1a);
            this.ListBoxFA.Location = point;
            this.ListBoxFA.Name = "ListBoxFA";
            size = new Size(0x156, 0x115);
            this.ListBoxFA.Size = size;
            this.ListBoxFA.TabIndex = 0x10;
            this.TABFinanzArtenBindingSource.DataMember = "TAB_FinanzArten";
            this.TABFinanzArtenBindingSource.DataSource = this.DatenschemaBMW;
            this.DatenschemaBMW.DataSetName = "DatenschemaBMW";
            this.DatenschemaBMW.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            size = new Size(0x156, 0x16a);
            this.ClientSize = size;
            this.Controls.Add(this.ListBoxFA);
            this.Controls.Add(this.ToolStrip1);
            this.Controls.Add(this.butOk);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "frmFA";
            this.ShowIcon = false;
            this.ShowInTaskbar = false;
            this.StartPosition = FormStartPosition.CenterParent;
            this.Text = "Einstellungen Finanzierungsarten";
            this.TopMost = true;
            this.ToolStrip1.ResumeLayout(false);
            this.ToolStrip1.PerformLayout();
            ((ISupportInitialize) this.TABFinanzArtenBindingSource).EndInit();
            this.DatenschemaBMW.EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private void ListBoxFA_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index >= 0)
            {
                e.DrawBackground();
                string[] strArray = this.ListBoxFA.Items[e.Index].ToString().Split(new char[] { ',' });
                SolidBrush brush = new SolidBrush(Color.FromName(strArray[1]));
                e.Graphics.FillRectangle(brush, (int) (e.Bounds.X + 0xd3), (int) (e.Bounds.Y + 1), (int) (e.Bounds.Width - 0xd5), (int) (e.Bounds.Height - 3));
                e.Graphics.DrawRectangle(Pens.Black, (int) (e.Bounds.X + 0xd3), (int) (e.Bounds.Y + 1), (int) (e.Bounds.Width - 0xd5), (int) (e.Bounds.Height - 3));
                if ((e.State & DrawItemState.Selected) != DrawItemState.None)
                {
                    e.Graphics.DrawString(strArray[0], e.Font, Brushes.White, (float) (e.Bounds.X + 1), (float) e.Bounds.Y);
                }
                else
                {
                    e.Graphics.DrawString(strArray[0], e.Font, Brushes.Black, (float) (e.Bounds.X + 1), (float) e.Bounds.Y);
                }
            }
        }

        private void ListBoxFA_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Operators.ConditionalCompareObjectEqual(this.ListBoxFA.SelectedItem, null, false))
            {
                this.butEdit.Enabled = false;
                this.butDel.Enabled = false;
            }
            else
            {
                this.butEdit.Enabled = true;
                this.butDel.Enabled = true;
            }
        }

        public void UpdateList()
        {
            IEnumerator enumerator = MyProject.Forms.Main.cs.Table_Finanzierungsarten.Rows.GetEnumerator();
            ListBox listBoxFA = this.ListBoxFA;
            listBoxFA.Items.Clear();
            try
            {
                
                while (enumerator.MoveNext())
                {
                    string str;
                    DataRow current = (DataRow) enumerator.Current;
                    if (Operators.ConditionalCompareObjectEqual(current["FA_KundeAuto"], "", false))
                    {
                        str = "";
                    }
                    else
                    {
                        str = Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject("    (Kunden Nr: ", current["FA_KundeAuto"]), ")"));
                    }
                    int num = listBoxFA.Items.Add(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(current["FA_Kbz"], " - "), current["FA_Name"]), str), ","), current["FA_Color"]), ","), Conversions.ToString(current["FA_ID"])));
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            listBoxFA = null;
            if (Operators.ConditionalCompareObjectEqual(this.ListBoxFA.SelectedItem, null, false))
            {
                this.butEdit.Enabled = false;
                this.butDel.Enabled = false;
            }
            else
            {
                this.butEdit.Enabled = true;
                this.butDel.Enabled = true;
            }
        }

        internal virtual ToolStripButton butDel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._butDel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.butDel_Click);
                if (this._butDel != null)
                {
                    this._butDel.Click -= handler;
                }
                this._butDel = value;
                if (this._butDel != null)
                {
                    this._butDel.Click += handler;
                }
            }
        }

        internal virtual ToolStripButton butEdit
        {
            [DebuggerNonUserCode]
            get
            {
                return this._butEdit;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.butEdit_Click);
                if (this._butEdit != null)
                {
                    this._butEdit.Click -= handler;
                }
                this._butEdit = value;
                if (this._butEdit != null)
                {
                    this._butEdit.Click += handler;
                }
            }
        }

        internal virtual ToolStripButton butNew
        {
            [DebuggerNonUserCode]
            get
            {
                return this._butNew;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.butNew_Click);
                if (this._butNew != null)
                {
                    this._butNew.Click -= handler;
                }
                this._butNew = value;
                if (this._butNew != null)
                {
                    this._butNew.Click += handler;
                }
            }
        }

        internal virtual Button butOk
        {
            [DebuggerNonUserCode]
            get
            {
                return this._butOk;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.butOk_Click);
                if (this._butOk != null)
                {
                    this._butOk.Click -= handler;
                }
                this._butOk = value;
                if (this._butOk != null)
                {
                    this._butOk.Click += handler;
                }
            }
        }

        internal virtual DatenschemaBMW DatenschemaBMW
        {
            [DebuggerNonUserCode]
            get
            {
                return this._DatenschemaBMW;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._DatenschemaBMW = value;
            }
        }

        internal virtual ListBox ListBoxFA
        {
            [DebuggerNonUserCode]
            get
            {
                return this._ListBoxFA;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                DrawItemEventHandler handler = new DrawItemEventHandler(this.ListBoxFA_DrawItem);
                EventHandler handler2 = new EventHandler(this.ListBoxFA_SelectedIndexChanged);
                if (this._ListBoxFA != null)
                {
                    this._ListBoxFA.DrawItem -= handler;
                    this._ListBoxFA.SelectedIndexChanged -= handler2;
                }
                this._ListBoxFA = value;
                if (this._ListBoxFA != null)
                {
                    this._ListBoxFA.DrawItem += handler;
                    this._ListBoxFA.SelectedIndexChanged += handler2;
                }
            }
        }

        internal virtual BindingSource TABFinanzArtenBindingSource
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TABFinanzArtenBindingSource;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TABFinanzArtenBindingSource = value;
            }
        }

        internal virtual ToolStrip ToolStrip1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._ToolStrip1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._ToolStrip1 = value;
            }
        }

        public enum fDetailMode
        {
            fEdit = 1,
            fNew = 2
        }
    }
}

